package risk.analysis;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.lucene.analysis.kr.utils.KoreanEnv;
import org.apache.lucene.analysis.kr.utils.Trie;
import org.apache.lucene.analysis.kr.morph.MorphException;
import org.apache.lucene.analysis.kr.morph.WordDBEntity;
import org.apache.lucene.analysis.kr.morph.WordEntry;
import org.apache.lucene.analysis.kr.utils.DBUtil;
import org.apache.lucene.analysis.kr.utils.FileUtil;
import org.apache.lucene.analysis.kr.utils.StringUtil;

/**
 * @author Ryu Seung Wan
 *
 */
public class DBDictionaryUpdate {
	
	private static Trie<String,WordEntry> dictionary;
	
	public static void main(String[] args){
		

		dictionary = new Trie<String, WordEntry>(true);
		List<String> strList = null;
		List<String> compounds = null;

		ArrayList<WordDBEntity> dicList = null;
		
		DBUtil du = new DBUtil();
		
		try {
			strList = FileUtil.readLines(KoreanEnv.getInstance().getValue(KoreanEnv.FILE_DICTIONARY),"UTF-8");
			strList.addAll(FileUtil.readLines(KoreanEnv.getInstance().getValue(KoreanEnv.FILE_EXTENSION),"UTF-8"));
			//compounds = FileUtil.readLines("compounds","UTF-8");		
			

			dicList = du.loadDictionaryOrg();
			
			du.updateDictionary(dicList);		
			
		} catch (IOException e) {	
			e.printStackTrace();
			new MorphException(e.getMessage(),e);
		} catch (Exception e) {	
			e.printStackTrace();
			new MorphException(e.getMessage(),e);
		}
		
	}
}
